import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/views/layout/index.vue'
import settingRouter from './modules/setting'
import employeeRouter from './modules/employee'
import departmentRouter from './modules/department'

// 动态路由
const asyncRoutes = [settingRouter,employeeRouter,departmentRouter]

// 静态路由
const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue'),
    hidden: true
  },
  {
    path: '/',
    redirect: '/dashboard',
    component: Layout,
    // 子节点
    children: [
      {
        path: 'dashboard', // 二级路由的地址
        component: () => import('@/views/dashboard/index.vue'),
        // 路由元信息
        meta: {
          title: '数据看板',
          icon: 'HomeOutlined'
        }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...constantRoutes,...asyncRoutes] // 合并动态路由与今天路由
})


export default router
